package com.Service;

import com.Dao.AdminDao;
import com.Dao.EngineerDao;
import com.Dao.UserDao;
import com.POJO.Admin;
import com.POJO.Engineer;
import com.POJO.User;
import com.Service.Imp.AdminServiceImp;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Service
public class AdminService extends ServiceImpl<AdminDao, Admin> implements AdminServiceImp {
    @Autowired
    private AdminDao adminDao;
    @Autowired
    private UserDao userDao;
    @Autowired
    private EngineerDao engineerDao;

    public Admin AdminLogin(String admin, String pwd){
        QueryWrapper<Admin> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("admin",admin);
        queryWrapper.eq("pwd",pwd);
        return adminDao.selectOne(queryWrapper);
    }

    public List<User> findAllUser(){
        QueryWrapper<User> queryWrapper=new QueryWrapper<>();
        return userDao.selectList(queryWrapper);
    }
    public List<Engineer> findAllEngineer(){
        QueryWrapper<Engineer> queryWrapper=new QueryWrapper<>();
        return engineerDao.selectList(queryWrapper);
    }
    public List<BigDecimal> getTotalMoney() {
        BigDecimal OrderTotalMoney=adminDao.getOrderTotalMoney();
        BigDecimal PoTotalMoney=adminDao.getPoTotalMoney();
        List<BigDecimal>  TotalMoney=new ArrayList<>();
        TotalMoney.add(OrderTotalMoney);
        TotalMoney.add(PoTotalMoney);
        return TotalMoney;
    }
}
